package com.stone.framework.batch.processor;

import java.util.function.Predicate;

import org.springframework.batch.item.ItemProcessor;

public class FilterItemProcessor<I> implements ItemProcessor<I, I> {

    private Predicate<I> predicate;

    @Override
    public I process(I item) throws Exception {
        if (predicate.test(item)) {
            return item;
        }
        return null;
    }

    public void setPredicate(Predicate<I> predicate) {
        this.predicate = predicate;
    }

}
